{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import theano as theano\n",
    "import theano.tensor as T\n",
    "import time\n",
    "import operator\n",
    "from utils import load_data, load_model_parameters_theano, generate_sentences\n",
    "from gru_theano import *\n",
    "import sys"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Reading CSV file...\n",
      "Parsed 502183 sentences.\n",
      "Found 193212 unique words tokens.\n",
      "Using vocabulary size 8000.\n",
      "The least frequent word in our vocabulary is 'playlist' and appeared 52 times.\n"
     ]
    }
   ],
   "source": [
    "# Load data (this may take a few minutes)\n",
    "VOCABULARY_SIZE = 8000\n",
    "X_train, y_train, word_to_index, index_to_word = load_data(\"data/reddit-comments-2015.csv\", VOCABULARY_SIZE)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Building model model from ./data/pretrained.npz with hidden_dim=128 word_dim=8000\n"
     ]
    }
   ],
   "source": [
    "# Load parameters of pre-trained model\n",
    "model = load_model_parameters_theano('./data/pretrained.npz')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Build your own model (not recommended unless you have a lot of time!)\n",
    "\n",
    "# LEARNING_RATE = 1e-3\n",
    "# NEPOCH = 20\n",
    "# HIDDEN_DIM = 128\n",
    "\n",
    "# model = GRUTheano(VOCABULARY_SIZE, HIDDEN_DIM)\n",
    "\n",
    "# t1 = time.time()\n",
    "# model.sgd_step(X_train[0], y_train[0], LEARNING_RATE)\n",
    "# t2 = time.time()\n",
    "# print \"SGD Step time: ~%f milliseconds\" % ((t2 - t1) * 1000.)\n",
    "\n",
    "# train_with_sgd(model, X_train, y_train, LEARNING_RATE, NEPOCH, decay=0.9)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "i do n't see it all .\n",
      "i do n't 4 expected a few years ago .\n",
      "that here go i just miss it again , friend .\n",
      "because there is no joke at all .\n",
      "i place hi out respected that you are lucky .\n",
      "crucial work .\n",
      "it seems .\n",
      "read about this system .\n",
      "controversial experience , you just have to hold your hands ignorant of your own .\n",
      "that 's more reliable than having too much like a profession .\n",
      "you are subs for the right to feeling like this is from negotiate .\n",
      "( because i quietly find out admitting they mexican talk . )\n",
      "i think they are very casual to confirm if not just melee .\n",
      "i 'll be twins , it was a fail muslims to influence .\n",
      "believe just it site and use loyal difficulty\n",
      "and thank you ?\n",
      "i strange to me , does n't mean it means consistent places ... lol .\n",
      "first home rock hook ! ! !\n",
      "laptop station , and support lower income tires , maxed , vs. influence .\n",
      "if i are some partner i quitting as well .\n",
      "and instinct on diseases that is n't receives for facing bitcoin .\n",
      "you pony that desire to trilogy you to yourself .\n",
      "i do n't think at all in my opinion , fucks the water them ?\n",
      "point them , i would look down to participate and get across the anywhere .\n",
      "you should even have a shitty story of fire and the double eggs .\n",
      "ca n't dc when i 'd be a varying dramatic player .\n",
      "i would n't do it .\n",
      "basically , most of your incidents staff should be a situations of music .\n",
      "offer my first 5-10 distinct magazine .\n",
      "it 's just been true either .\n",
      "thank you .\n",
      "god look some touched in the thread got similar fun .\n",
      "when they enter this , it was because of it .\n",
      "that is crazy .\n",
      "anyways , great bullshit .\n",
      "the approaches is definitely a new one .\n",
      "that pop branch .\n",
      "`` i 'm feeling better ! ''\n",
      "i should do it legit .\n",
      "also that 's boring to be mentally fucked up pc .\n",
      "her dawn is spiders .\n",
      "honestly i 'm twist damn over the hour crack it a bit emphasis .\n",
      "so that 's pop in them .\n",
      "sudden sony would have done this .\n",
      "that 's a resume with throwing everyone !\n",
      "i 'll sadness , cs calendar to situation , but honestly ?\n",
      "however the against failure is switching to the salary .\n",
      "i have no idea he could reliable it several clubs notice .\n",
      "holy shit man !\n",
      "the new one !\n",
      "this is approaching engineers at those to make you realize that .\n",
      "i 'm glad anyone has to go !\n",
      "- til fan made a lot of mail out and mandatory .\n",
      "my upon gym is today ... was n't that fan top-level ''\n",
      "i 'd imagine that 's very pacific and there might be a cancelled horse .\n",
      "something na system will overall have in consumer neighborhood .\n",
      "my free pets up shit tough instructions right now .\n",
      "that sucks .\n",
      "foul is an alternative to fantasy then porn barely it’s come to a realistic quarter\n",
      "he at more statistically limit superiority events , though others are not have won time .\n",
      "i think they have to site bonds .\n",
      "you can see what you described about : )\n",
      "not very much too , certainly at parking destructive spends more\n",
      ": ) they are bold , but not somewhere good than something else .\n",
      "dial all and temperatures , most change in the site .\n",
      "its worth it so i get mall is so close .\n",
      "if they have no idea something on so eliminate those comics .\n",
      "lucky to long when you lose both the existing .\n",
      "you can make fun of yourself .\n",
      "thank you very much just !\n",
      "i would go on the wheel of their feature .\n",
      "it should n't have wanted much much more capable of weed trigger lion sounds\n",
      "whereas legs alright .\n",
      "i verify how few of these right now , but kits hands can oblivion .\n",
      "honestly it 's considered av after you get earth depending on what were bad .\n",
      "other than that , you can check out if you have chaos gear .\n",
      "good earned to them for anything new crit ! ''\n",
      "that 's further sex .\n",
      "yeah , i have algo complain about going up to swimming in the future .\n",
      "probably not recognition .\n",
      "chances are , i giants from cap .\n",
      "that whole intentions really feels nothing .\n",
      "you like the colored or missions , fnatic , angry moon .\n",
      "it will be more patients than abuse like a country which is adc .\n",
      "writer earlier !\n",
      "he likely brings that greatly .\n",
      "liability you besides paying her own 4. is not united to convince anyone ?\n",
      "hyper famous guards nyc class .\n",
      "saturday comes over , bike mode , etc .\n",
      "and collected mindset . )\n",
      "should you be easily fast charging asap ?\n",
      "that 's bitch .\n",
      "that listening to an interview and so was going to release you afterwards .\n",
      "not everyone became collected by the destiny version of the game .\n",
      "i can remember that .\n",
      "that 's lighter than anyone .\n",
      "meaningless error .\n",
      "i 'm also really doses to throw excited so much when i get home .\n",
      "wishing i may think it 's good ?\n",
      "my podemos ' huge pretend for these are me .\n"
     ]
    }
   ],
   "source": [
    "generate_sentences(model, 100, index_to_word, word_to_index)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
